extends Sprite2D

# 拖动精灵条时发出的信号
signal draged(mouse_position: Vector2)

@onready var _rect: Rect2 = get_rect()

# 未处理的输入事件：如果左键在精灵中按下并拖动，触发拖动精灵条的事件
func _unhandled_input(event: InputEvent) -> void:
	var event_mouse_motion: InputEventMouseMotion = event as InputEventMouseMotion
	if (not event_mouse_motion or event_mouse_motion.button_mask != MOUSE_BUTTON_MASK_LEFT or 
			event_mouse_motion.relative.x == 0):
		return
	if not _rect.has_point(get_local_mouse_position()):
		return
	draged.emit(event_mouse_motion.position)
